import store from "@/store";
// 用来控制页签的显示
export function hasTabsPermission(permission) {
  const myTabs = store.getters.tabs;
  return myTabs.indexOf(permission) > -1;
}
// 用来控制按钮的显示
export function hasBtnsPermission(val) {
  const myBtns = store.getters.buttonList;
  for (let i = 0; i < myBtns.length; i++) {
    const item = myBtns[i];
    if (item.code == val) {
      return true;
    }
  }
  return false;
}
function filterModuleFn(val, moduleName) {
  const myModuleList = store.getters.moduleFieldConfigList;
  let myModules = [];
  for (let j = 0; j < myModuleList.length; j++) {
    const ej = myModuleList[j];
    if (ej.funcModuleName == moduleName) {
      myModules = ej.moduleFieldList;
      break;
    }
  }
  for (let i = 0; i < myModules.length; i++) {
    const item = myModules[i];
    if (item.fieldName == val) {
      return item;
    }
  }
  return {};
}
// 用来控制页面中搜索、表格的显示
export function hasModulePermission(val, moduleName) {
  const m = filterModuleFn(val, moduleName);
  return m.display || false;
}
// 用来显示模块描述
export function getModuleDescription(val, moduleName) {
  const m = filterModuleFn(val, moduleName);
  return m.fieldDesc || "";
}
